package com.uujava.minibox.ui.cartoon.pulse;
import java.awt.Color;

import javax.swing.JComponent;
import javax.swing.border.CompoundBorder;

import org.jdesktop.animation.timing.Animator;
import org.jdesktop.animation.timing.interpolation.PropertySetter;
/**
 * 功能:边框渐变动画封装类
 * @author k 2013年7月30日16:36:24
 *
 */
public class Pulse {
	private Animator animator = null;
	private int time = 900;// 动画过度时间
    private Color color=new Color(0x54A4DE);//边框的渐变颜色
    
    public Color getColor() {
		return color;
	}

	public void setColor(Color color) {
		this.color = color;
	}
	public Pulse() {}

	public Pulse(int time) {
		this.time = time;
	}

	public int getTime() {
		return time;
	}

	public void setTime(int time) {
		this.time = time;
	}

	public void setBuildPulsating(JComponent component) {

		PulsatingBorder border = new PulsatingBorder(component);
		border.setColor(color);
		component.setBorder(new CompoundBorder(component.getBorder(), border));

		PropertySetter setter = new PropertySetter(border, "thickness", 0.0f,
				1.0f);
		animator = new Animator(time, Animator.INFINITE,
				Animator.RepeatBehavior.REVERSE, setter);
	}

	public void Start() {
		if (animator != null)
			animator.start();
	}

	public void Stop() {
		if (animator != null)
			animator.stop();
	}
}
